package com.example.callbackevent;

import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK)
            return true;
        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP)
            Toast.makeText(this, "音量增加", Toast.LENGTH_LONG).show();
        return super.onKeyDown(keyCode, event);
    }


}
